<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./bootstrap/bootstrap.min.css" />
  </head>
  <body>
    <button id="btn">打开轻提示</button>
    <div
      id="liveToast"
      class="toast"
      role="alert"
      aria-live="assertive"
      aria-atomic="true"
    >
      登录成功
    </div>

    <script src="./bootstrap/bootstrap.min.js"></script>

    <script>
      document.querySelector('#btn').addEventListener('click', function () {
        // 弹出轻提示
        // 实例化轻提示对象
        const toast = new bootstrap.Toast(document.querySelector('#liveToast'), {
            // 打开后会在1.5秒后自动消失
            delay: 1500
        })
        toast.show()
      })
    </script>
  </body>
</html>
